package com.tangyuan.task;

import com.tangyuan.manager.AutoManager;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Slf4j
public class TimedTask {

    @Autowired
    AutoManager autoManager;

    private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @XxlJob("updateTask")
    public void updateTask(){
        System.out.println("updateTask开始执行:" + format.format(new Date()));
        autoManager.updateTask();
        System.out.println("updateTask执行时间:"+format.format(new Date()));
    }
}
